#pragma once
#include <vector>
#include "DrawView.h"
namespace UILib
{
    typedef struct UITreeObserver{
        virtual void OnSizeChange( const SIZE szClient ) {};
    }UITreeObserver, *PUITreeObserver;
    using namespace std;
    class CDrawUITree : public TipsListenser
    {
    public:
        CDrawUITree(const HWND hWnd = NULL, PUITreeObserver pObserver = NULL );
        virtual ~CDrawUITree(void);

        void SetHWnd( const HWND hWnd ) { hWnd_ = hWnd; };
        HWND GetHWnd() const { return hWnd_; };

        void SetObserver( PUITreeObserver pObserver );

        void AddChildren( CDrawView* pChildren, const int nPos = -1 );
        CDrawView* GetChildrenByID(const UINT uID);

        int GetChildrenCount() const;
        CDrawView* GetChildrenByIndex(const UINT uIndex);
        
        bool CheckInvalidateRect( RECT& rc );

        virtual void HandleMessage( UINT uMsg, WPARAM wParam, LPARAM lParam, HWND hWnd, BOOL& bHandled );
        virtual void DrawElement( const HDC hDC, const RECT &rcPaint ); 

        void OnShowTips( const wstring wstrTips, const POINT pt, const RECT rcElem );
        
        void Layout( const RECT rcClient );
    private:
        vector<CDrawView*>  vecElem_;
        HWND                hWnd_;
        void*               pToolTips_;
        PUITreeObserver     pObserver_;
    };

}